define(['util'], function (Util) {
    function ViewModel(/*{mapOptions:{minZoom:,maxZoom:,mapType:,enableHighResolution:,enableAutoResize:,enableMapClick:}}*/params) {
        $.extend(this,params);
        var scope = this;

        scope._id = 'map_{0}'.formatTpl(Util.uuid(4,16));
        scope._css = {'h-100':true};
    }

    ViewModel.prototype.koDescendantsComplete = function (node) {
        var map = new BMap.Map(this._id,this.mapOptions);

        map.disableDoubleClickZoom();
        map.enableScrollWheelZoom();

        if(this.onReady) this.onReady(map);
    };

    BMap.Map.prototype.setMapStyleV2_Custom = function (/*{styleId:,timeout:}*/data) {
        var scope = this;
        var timeout = data.timeout;

        delete data['timeout'];

        if(timeout){
            scope.disableDragging();
            scope.disableScrollWheelZoom();

            setTimeout(function () {
                scope.enableDragging();
                scope.enableScrollWheelZoom();
                scope.setMapStyleV2(data);
            },timeout);
        }
        else {
            this.setMapStyleV2(data);
        }
    };

    return ViewModel;
});
